/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helper;

import helper.Config;
import java.util.HashSet;
import java.util.Random;

/**
 *
 * @author Andrzej
 */
public class BagWithNumbers{
    
    private HashSet<Integer> drawnNumbers = new HashSet<Integer>();//numbers
    private Random random = Config.getSalt();
    private int maxNumber; //exclusive

    /**
     *
     * @param number drawed number will be smaller than number and equal or greater than 0
     */
    public BagWithNumbers(int number) {
        maxNumber = number;

    }
    public int drawNumber(){
        if (drawnNumbers.size() == maxNumber)
            throw new RuntimeException("no numbers left to draw");
        int i = random.nextInt(maxNumber);
        while (drawnNumbers.contains(i))
            i = random.nextInt(maxNumber);

        drawnNumbers.add(i);
        return i;


    }
}
